package com.hui.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @BelongsProject: demo
 * @BelongsPackage: com.hui.config
 * @Author: HUI
 * @CreateTime: 2021-12-06 15:03
 * @Description:
 */
//自动填充策略，上架时间自动填充
@Component
@Slf4j
public class myMetaObjectHandler implements MetaObjectHandler {
    //插入时填充策略
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("dop",new Date(),metaObject);//Book 表
        this.setFieldValByName("time",new Date(),metaObject);//News 表

    }

    //更新时填充策略
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("dop",new Date(),metaObject);
        this.setFieldValByName("time",new Date(),metaObject);
    }
}
